<readme th:if="false">
    <!--
    说明:
    使用方式，在页面中导入即可
    totalPageSize=总页数，pageNo=第几页，onclick=点击后的事件，this当前点击的元素，no，当前点击的页数，thisNo当前是第几页

    <div class="thr-pages" th:include="/pages.html"
        th:with="onclick='xx(this,no,thisNo)',totalPageSize=${data.totalPageSize},pageNo=${data.pageNo}"/>
    -->
</readme>
<script type="text/javascript">
    function a(v, no, thisNo) {
        if (v && v != "") {
            eval(v);
        } else {
            if (no != thisNo) {
                var currentUrl = location.href;
                var index = currentUrl.indexOf("?");
                if (index == -1) {
                    currentUrl = currentUrl + "?pageNo=" + no;
                } else {
                    var pageNoIndex = currentUrl.indexOf("pageNo=", index);
                    if (pageNoIndex == -1) {
                        if (currentUrl.indexOf("&", index) == -1) {
                            currentUrl= currentUrl + "&pageNo=" + no;
                        } else {
                            currentUrl= currentUrl + "pageNo=" + no;
                        }
                    } else {
                        var pageNoEndIndex = currentUrl.indexOf("&", pageNoIndex);
                        var left = currentUrl.substring(0, pageNoIndex + "pageNo=".length);

                        if (pageNoEndIndex == -1) {
                            currentUrl = left + no;
                        } else {
                            currentUrl = left + no + currentUrl.substring(pageNoEndIndex);
                        }
                    }
                }
                location.href = currentUrl;
            }
        }
    }

</script>
<div th:if="${totalPageSize > 0}">
    <div th:if="${pageNo > 5}" class="thr-pages-item thr-pages-item-first"
         th:onclick="a([[${#strings.replace(#strings.replace(onclick,'no',1),'thisNo', pageNo)}]], 1, [[${pageNo}|]])">首页</div>
    <div th:if="${pageNo > 1}" class="thr-pages-item thr-pages-item-prev"
         th:onclick="a([[${#strings.replace(#strings.replace(onclick,'no',pageNo-1),'thisNo', pageNo)}]],[[|${pageNo-1}]],[[${pageNo}|]])">上一页</div>
    <div
            th:each="i,stat:${#numbers.sequence(pageNo - 4 < 1 ? 1 : pageNo - 4, pageNo + 4 > totalPageSize ? totalPageSize : pageNo + 4)}"
            th:onclick="a([[${#strings.replace(#strings.replace(onclick,'no',i),'thisNo', pageNo)}]], [[|${i}]],[[${pageNo}|]])"
            th:class="| ${i == pageNo ? 'thr-pages-item-select':''} thr-pages-item|"
            th:text="${i}"></div>
    <div th:if="${pageNo < totalPageSize}"
         class="thr-pages-item thr-pages-item-next"
         th:onclick="a([[${#strings.replace(#strings.replace(onclick,'no',pageNo+1),'thisNo', pageNo)}]], [[|${pageNo+1}]],[[${pageNo}|]])">下一页</div>
    <div th:if="${pageNo < totalPageSize - 4}"
         class="thr-pages-item thr-pages-item-last"
         th:onclick="a([[${#strings.replace(#strings.replace(onclick,'no',totalPageSize),'thisNo', pageNo)}]], [[|${totalPageSize}]],[[${pageNo}|]])">末页</div>
    <div class="clear"></div>
</div>
<div th:unless="${totalPageSize > 0}">
    <div class="thr-pages-item thr-pages-item-select">0</div>
</div>